/* @(#)ctrl.hh
 * Time-stamp: <2009-01-05 13:23:20 root>
 * Copyright 2008 Julian Qian
 * Author: lancer@pdn
 * Version: $Id: ctrl.hh,v 0.0 2008/12/30 03:51:52 lancer Exp $
 * Keywords: 
 */

#ifndef _CTRL_H
#define _CTRL_H 1

#include "common.hh"

#define MSG_TYPE_ALARM 1
#define MSG_TYPE_MSG   2
#define MSG_TYPE_CHECK 3


#define MSG_KEY 8600 // TODO: ftok
#define MSG_LEN 20

typedef struct {
    long int msg_type;
    char data[MSG_LEN];
} CTRL_MSG;

typedef struct {
    devid_t devid;
    alarm_t alarm;
} ALARM_PAIR;

class Alarm;
class Heart;

class Ctrl {
public:
    void msg_servo();
    static void push_alarm(char* msg);
    static void check_devid(char* devid);

    Ctrl();
    virtual ~Ctrl();

protected:
    bool parse_msg_alarm(char* buf, ALARM_PAIR* ap);
    Alarm* _ala;
    Heart* _ht;
};


#endif /* _CTRL_H */

